import * as actionTypes from "./constance";
import { getAlbum, getAlbumComment, getArtistAlbum } from "@/services/album";

const album = (res) => ({
  type: actionTypes.GET_ALBUM,
  topAlbums: res,
});
const albumComment = (res) => ({
  type: actionTypes.GET_ALBUMCOMMENT,
  albumComments: res,
});
const artistAlbum = (res) => ({
  type: actionTypes.GET_ARTISTALBUM,
  artistAlbum: res,
});

export const albumAction = (id) => {
  return (dispatch) => {
    getAlbum(id).then((res) => {
      dispatch(album(res));
    });
  };
};

export const albumCommentAction = (id, limit, offset) => {
  return (dispatch) => {
    getAlbumComment(id, limit, offset).then((res) => {
      dispatch(albumComment(res));
    });
  };
};

export const artistAlbumAction = (id, limit, offset) => {
  return (dispatch) => {
    getArtistAlbum(id, limit, offset).then((res) => {
      dispatch(artistAlbum(res));
    });
  };
};
